package com.material.factory.service.impl;

import java.util.List;

import com.github.pagehelper.PageInfo;
import com.material.common.utils.DateUtils;
import com.material.factory.domain.FactoryNotice;
import com.material.factory.mapper.FactoryNoticeMapper;
import com.material.factory.service.IFactoryNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 通知公告Service业务层处理
 *
 * @author ruoyi
 * @date 2025-06-20
 */
@Service
public class FactoryNoticeServiceImpl implements IFactoryNoticeService
{
    @Autowired
    private FactoryNoticeMapper factoryNoticeMapper;

    /**
     * 查询通知公告
     *
     * @param id 通知公告主键
     * @return 通知公告
     */
    @Override
    public FactoryNotice selectFactoryNoticeById(Long id)
    {
        return factoryNoticeMapper.selectFactoryNoticeById(id);
    }

    /**
     * 查询通知公告列表
     *
     * @param facttoryNotice 通知公告
     * @return 通知公告
     */
    @Override
    public List<FactoryNotice> selectFactoryNoticeList(FactoryNotice facttoryNotice)
    {
        return factoryNoticeMapper.selectFactoryNoticeList(facttoryNotice);
    }

    /**
     * 新增通知公告
     *
     * @param factoryNotice 通知公告
     * @return 结果
     */
    @Override
    public int insertFactoryNotice(FactoryNotice factoryNotice)
    {
        factoryNotice.setCreateTime(DateUtils.getNowDate());
        return factoryNoticeMapper.insertFactoryNotice(factoryNotice);
    }

    /**
     * 修改通知公告
     *
     * @param factoryNotice 通知公告
     * @return 结果
     */
    @Override
    public int updateFactoryNotice(FactoryNotice factoryNotice)
    {
        return factoryNoticeMapper.updateFactoryNotice(factoryNotice);
    }

    /**
     * 批量删除通知公告
     *
     * @param ids 需要删除的通知公告主键
     * @return 结果
     */
    @Override
    public int deleteFactoryNoticeByIds(Long[] ids)
    {
        return factoryNoticeMapper.deleteFactoryNoticeByIds(ids);
    }

    /**
     * 删除通知公告信息
     *
     * @param id 通知公告主键
     * @return 结果
     */
    @Override
    public int deleteFactoryNoticeById(Long id)
    {
        return factoryNoticeMapper.deleteFactoryNoticeById(id);
    }

    @Override
    public PageInfo<FactoryNotice> selectFactoryNoticePageList(FactoryNotice query) {
        List<FactoryNotice> factoryNotices = factoryNoticeMapper.selectFactoryNoticeList(query);
        PageInfo<FactoryNotice> pageInfo = new PageInfo<>(factoryNotices);
        return pageInfo;
    }

    @Override
    public FactoryNotice selectFactoryNoticeByDate(String currentDate, Long factoryId) {
        return factoryNoticeMapper.selectFactoryNoticeByDate(currentDate,factoryId);
    }
}
